attribute highp vec4 va_vertices;
attribute highp vec4 va_normals;
attribute highp vec4 va_colors;

uniform highp mat4 vu_proj;
uniform highp mat4 vu_view;
uniform highp mat4 vu_model;
uniform highp mat4 vu_normal;

uniform highp vec4 m_diffuse;
uniform highp vec4 m_ambient;
uniform highp vec4 m_specular;

uniform highp vec4 l_diffuse;
uniform highp vec4 l_ambient;
uniform highp vec4 l_specular;
uniform highp vec4 l_position;

uniform bool vu_isPoint;
uniform vec4 vu_pointColor;
uniform float vu_pointSize;

uniform highp vec3 vu_eyepos;

varying highp vec4 color;

void main(void)
{
    gl_Position = vu_proj*vu_view*vu_model*vec4(va_vertices.xyz,1.0);
    gl_PointSize = 1.0;

    vec3 vertex = vec3(vu_model*vec4(va_vertices.xyz,1.0));
    vec3 light = normalize(l_position.xyz-vertex);
    vec3 normal = vec3(vu_normal*normalize(va_normals));
    normal = normalize(normal);
    vec3 eye_ver = normalize(vu_eyepos-vertex);

    float NdotL = max(0.0, dot(light,normal));
    float NdotH = max(0.0, dot(normal,normalize(eye_ver+light)));

    color = m_ambient*l_ambient;// + m_diffuse*l_diffuse*NdotL + m_specular*l_specular*NdotH;
    color += m_diffuse*l_diffuse*NdotL;// + m_specular*l_specular*NdotH;
    color += m_specular*l_specular*pow(NdotH,60.0);

    if(vu_isPoint)
    {
        gl_PointSize = vu_pointSize;
        color = vu_pointColor;
    }
}
